package com.zrrd.wemedia.controller.v1;

import com.zrrd.model.common.dtos.ResponseResult;
import com.zrrd.model.common.enums.AppHttpCodeEnum;
import com.zrrd.model.wemedia.dtos.WmChannelDto;
import com.zrrd.model.wemedia.dtos.WmChannelPageReqDto;
import com.zrrd.wemedia.service.WmChannelService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author WanJl
 * @version 1.0
 * @title WmChannelController
 * @description
 * @create 2023/9/21 14:29
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }


    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmChannelPageReqDto dto){
        return wmChannelService.findAll(dto);
    }
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannelDto dto){
        return wmChannelService.save(dto);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannelDto dto){
        return wmChannelService.update(dto);
    }
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        boolean b = wmChannelService.removeById(id);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

}
